﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ModelLibrary;

namespace WebC
{
    public partial class _Default : clsBaseForm
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Session.Clear();
            if (Request["logincode"] != null)
            {
                checkLogin();
            }
        }
        protected void checkLogin()
        {
            clsSys clss = null;
            int iUid = 0;
            string sName = "";
            try
            {
                clss = new clsSys();
                string sLoginCode = Convert.ToString(Request["logincode"]);
                string sPwd = this.MD5Encrypt(Convert.ToString(Request["loginpwd"]));
                clss.checkLogin(ref iUid, ref sName, sLoginCode, sPwd);
            }
            catch (Exception ex)
            {
                errorUrl(ex.ToString());
                return;
            }
            finally
            {
                if (clss != null)
                {
                    clss.Dispose();
                }
            }
            if (iUid == 0)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "fail", "<script>alert('用户名或密码错误！！');</script>");
            }
            else
            {
                iUserId = iUid;
                sUserName = sName;  
                Response.Redirect("index.aspx");
            }
        }

    }
}